package com.lancoo.tyjx.multichatroom.activity;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.lancoo.tyjx.multichatroom.R;
import com.lancoo.tyjx.multichatroom.view.BottomDialog;


public class ShowPicFragment extends BottomDialog {
    private LinearLayout ll_viewArea;
    private LinearLayout.LayoutParams parm;
    private ViewArea viewArea;
    private ImageView mIvBack;

    public static ShowPicFragment getInstance(String picPath) {
        ShowPicFragment showPicFragment = new ShowPicFragment();
        Bundle bundle = new Bundle();
        bundle.putString("picPath", picPath);
        showPicFragment.setArguments(bundle);

        return showPicFragment;
    }

    @Override
    protected View createView(LayoutInflater inflater, ViewGroup container) {
        View view = inflater.inflate(R.layout.acti_show_pic, container);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        ll_viewArea = (LinearLayout) view.findViewById(R.id.ll_viewArea);
        mIvBack = view.findViewById(R.id.iv_back);
        parm = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
//        parm.gravity =  Gravity.CENTER;
        viewArea = new ViewArea(getContext(), getArguments().getString("picPath"));    //自定义布局控件，用来初始化并存放自定义imageView
        ll_viewArea.addView(viewArea, parm);

        ll_viewArea.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        mIvBack.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}